public class test9 {
    public static void main(String[] args) {
        Long n = 59084709587505L;
        int count = 0;
        for(long a=1 ; a <= n ; a *= 3){
            for(long b=1 ; b <= n ; b *= 5){
                for(long c=1 ; c <= n ; c *= 7){
                    if (a*b*c <= n && a * b * c > 0) count++;
                }
            }
        }
        System.out.println(count - 1);
    }
}
